<!--{subtemplate inc/header}-->
<div class="blank12"></div>
<div class="hbox">
	<div class="list-goods-search">
		<div class="lgs-item lgs-cate lgs-search">
			<div class="lgsi-title">搜索</div>
			<div class="lgsi-list">
				<!--{if MODULE_NAME == 'now'}-->
				<span>$_FANWE[current_city][name]今日团购</span>
				<!--{else}-->
				<span>$_FANWE[current_city][name]往期团购</span>
				<!--{/if}-->
				<span>关键字:</span>
				<span style="color:#F00;">$keyword</span>
			</div>
		</div>
	</div>
	<div class="list-goods-sort">
		<div class="sort" style="margin-left:0;">
			<a href="javascript:;"{if empty($sort)} class="default"{/if} sort="">默认排序</a>
			<a href="javascript:;"{if $sort == 'spd'} class="currentd" sort="spa"{elseif $sort == 'spa'} class="currenta" sort="spd"{else} sort="spa"{/if}>价格排序</a>
			<a href="javascript:;"{if $sort == 'dd'} class="currentd" sort="da"{elseif $sort == 'da'} class="currenta" sort="dd"{else} sort="da"{/if}>折扣排序</a>
			<a href="javascript:;"{if $sort == 'bd'} class="currentd" sort="ba"{elseif $sort == 'ba'} class="currenta" sort="bd"{else} sort="bd"{/if}>销量排序</a>
			<a href="javascript:;"{if $sort == 'etd'} class="currentd" sort="eta"{elseif $sort == 'eta'} class="currenta" sort="etd"{else} sort="eta"{/if}>时间排序</a>
		</div>
		<div class="display {dynamic getDisplayMode}">
			<a href="javascript:;" class="d_grid" mode="grid">网格</a>
			<a href="javascript:;" class="d_row" mode="row">列表</a>
		</div>
	</div>
	<div class="blank9"></div>
	<div id="body-left" class="fl">
		<div id="goods_list_body" class="goods-{dynamic getDisplayMode}-body">
			<div class="glb-list" style="border-top:solid 1px #eb5106;">
			<!--{if !empty($goods_list)}-->
			<ul>
				<!--{loop $goods_list $goods}-->
				<li class="item">
					<div class="site_gname">
						<div class="site">
							<a href="$goods[site_url]" target="_blank">$goods[site_name]</a>
						</div>
						<div class="name">
							<a class="highlight-box" href="$goods[url]" target="_blank" title="{$goods[site_name]}：{$goods[city]}今日团购:$goods[name]" style="text-align:left;">$goods[name]</a>
						</div>
					</div>
					<div class="img">
						<a href="$goods[url]" target="_blank"><img src="$goods[small_img]" alt="{$goods[site_name]}：{$goods[city]}今日团购:$goods[name]" /></a>
					</div>
					<div class="attrs-list">
						<p class="sprice al">现价：<span>$goods[shop_price_format]</span></p>
						<p class="bought ar">销量：<span>$goods[bought]</span></p>
						<p class="mprice al">原价：<b>$goods[market_price_format]</b></p>
						<p class="post ar">评论：<span>$goods[post_count]</span></p>
						<p class="discount al">折扣：<span>$goods[discount]</span>折</p>
						<p class="collect ar">收藏：<span>$goods[collect_count]</span></p>
						<p class="buy al"><a href="$goods[url]" target="_blank"><img src="{TPL_PATH}images/btn-1.gif" /></a></p>
						<p class="click ar">点击：<span>$goods[click_count]</span></p>
					</div>
					<div class="attrs-text attrs1">
						现价：<span class="sprice">$goods[shop_price_format]</span>
						原价：<b>$goods[market_price_format]</b>
						折扣：<span>$goods[discount]折</span>
						销量：<span>$goods[bought]</span>
					</div>
					<div class="attrs-text attrs2">
						<p class="post">评论：<span>$goods[post_count]</span></p>
						<p class="collect">收藏：<span>$goods[collect_count]</span></p>
						<p class="click">点击：<span>$goods[click_count]</span></p>
						<p class="buy"><a href="$goods[url]" target="_blank"><img src="{TPL_PATH}images/btn-1.gif" /></a></p>
					</div>
					<!--{if MODULE_NAME == 'now'}-->
					<div class="time settime" endTime="$goods[end_time]">
						$goods[end_time_lag]
					</div>
					<!--{else}-->
					<div class="time">
						结束时间：$goods[end_time_format]
					</div>
					<!--{/if}-->
					<!--{if $goods['is_best'] == 1}-->
					<span class="best"></span>
					<!--{elseif $goods['is_new'] == 1}-->
					<span class="new"></span>
					<!--{/if}-->
				</li>
				<!--{/loop}-->
			</ul>
			<!--{else}-->
			<div class="empty">没有找到符合条件的团购活动！</div>
			<!--{/if}-->
			<!--{subtemplate inc/pages}-->
			<div class="blank20"></div>
			</div>
		</div>
	</div>
	<div id="body-right" class="fr">
	<!--{subtemplate inc/common/right}-->
	</div>
</div>
<script type="text/javascript">
var city = "{CURRENT_CITY_PY}";
var sortOrder = "$sort";
var keyword = encodeURIComponent("$keyword");
var searchTxt = "$search_txt";
var route = $_FANWE['setting']['url_route'];
var depr = "-";
var indexUrl = decodeURIComponent("{echo U(MODULE_NAME.'/search',array('city_py'=>'_city_','sort'=>'_sort_','keyword'=>'_keyword_'))}");

jQuery(function($){
	$(".img img").lazyload({"placeholder":"{TPL_PATH}images/img_loading.gif","failurelimit":10});
	
	$(".list-goods-sort .sort a").click(function(){
		sortOrder = this.getAttribute("sort");
		goToUrl();
	});

	$(".display a").click(function(){
		mode = this.getAttribute("mode");
		$.cookie(COOKIE_PRE + 'display_mode', mode,{"expires":7});
		$("#goods_list_body").attr("className","goods-"+mode+"-body");
		$(".list-goods-sort .display").attr("className","display "+mode);	
	});
	
	$(".highlight-box").each(function(){
		var txt = $(this).text();
		var count = searchTxt.length;
		var reg;
        var t = '';
		for(var i = 0; i < count; i++)
		{
            t = searchTxt.substr(i,1);
			reg = new RegExp(t,"g");
			txt = txt.replace(reg,'<span class="highlight">'+ t +'</span>');
		}
		
		$(this).html(txt);
	});
});

function goToUrl()
{
	indexUrl = clearParm(indexUrl,'_keyword_',keyword,'keyword');
	indexUrl = clearParm(indexUrl,'_city_',city,'city_py');
	indexUrl = clearParm(indexUrl,'_sort_',sortOrder,'sort');
	
    //2011-02-10 update
    var fun = function(){
        location.href=indexUrl;
    };

    setTimeout(fun,1);
}

function clearParm(url,search,replace,parm)
{
	if(replace == "")
	{
		if(route > 0)
			return url.replace(depr+parm+depr+search,"");
		else
			return url.replace("&"+parm+"="+search,"");
	}
	else
		return url.replace(search,replace);
}
</script>
<!--{subtemplate inc/footer}-->